package com.lai.note.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.lai.note.R;
import com.lai.note.adapter.WenanRecyclerAdapter;
import com.lai.note.dto.ResponseResult;
import com.lai.note.model.Wenan;
import com.lai.note.service.WenanService;
import com.lai.note.util.GsonUtil;
import com.lai.note.util.ListWenanUtil;
import com.lai.note.util.RetrofitRequest;
import com.lai.note.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

public class RecordsWenanFragment extends Fragment {
    public RecordsWenanFragment(){
        super(R.layout.listwenan_recyclerview);
    }

    private RecyclerView recyclerView;
    private WenanRecyclerAdapter adapter;
    private LinearLayoutManager layoutManager;
    private List<Wenan> wenans = new ArrayList<Wenan>();


    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
        initDatas();
    }

    private void initViews(){
        recyclerView = getView().findViewById(R.id.wenan_recyclerview);
        adapter = new WenanRecyclerAdapter(wenans);
        layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
    }

    private void initDatas(){
        ListWenanUtil.initDatas(getContext(),adapter);
    }

}
